package app.engine.enums;

/**
 * @Description 走法评分器(进攻)，定义不同模式的评分标准
 * @Date 2022/4/18 22:04
 * @Created by LYP
 */
public enum MoveScoreAttackType {
    // 活二
    TWO(2, 0, 5),
    // 冲二
    TWO_END_ONE(2, 1, 2),
    // 活三
    THREE(3, 0, 50),
    // 冲三
    THREE_END_ONE(3, 1, 6),
    // 活四
    FOUR(4, 0, 200),
    // 冲四
    FOUR_END_ONE(4, 1, 8),
    // 五连
    FIVE(5, 0, 10000),
    FIVE_END_ONE(5, 1, 10000),
    FIVE_END_TWO(5, 2, 10000),
    ;

    // 棋串中棋子数
    private int chessCount;

    // 棋串末端对方棋子数
    private int endCount;

    // 分值
    private int score;

    MoveScoreAttackType(int chessCount, int endCount, int score) {
        this.chessCount = chessCount;
        this.endCount = endCount;
        this.score = score;
    }



    public int getChessCount() {
        return chessCount;
    }

    public int getEndCount() {
        return endCount;
    }

    public int getScore() {
        return score;
    }

    public static int matchScore(int chessCount, int endCount) {
        //System.out.println("匹配chessCount="+chessCount+" endCount="+endCount);
        MoveScoreAttackType[] moveScoreAttackTypes = MoveScoreAttackType.values();
        for (MoveScoreAttackType moveScoreAttackType : moveScoreAttackTypes) {
            if (moveScoreAttackType.getChessCount() == chessCount && moveScoreAttackType.getEndCount() == endCount) {
                return moveScoreAttackType.getScore();
            }
            if (moveScoreAttackType.getChessCount() == 5
                    && moveScoreAttackType.getChessCount() <= chessCount
                    && moveScoreAttackType.getEndCount() == endCount) {
                return moveScoreAttackType.getScore();
            }
        }
        return 0;
    }

}
